package book;

public class bookList {
    private Book[] books=new Book[10];
    private int usesize;
    public bookList(){
        books[0]=new Book("三国演义","罗贯中",10,"小说");
        books[1]=new Book("西游记","吴承恩",59,"小说");
        books[2]=new Book("红楼梦","曹雪芹",16,"小说");
        this.usesize=3;
    }

    public Book getBooks(int pos) {
        return books[pos];
    }

    public int getUsesize() {
        return usesize;
    }

    public void setBooks(int i,Book book) {
        this.books[i] = book;
    }

    public void setUsesize(int usesize) {
        this.usesize = usesize;
    }

    public Book[] getBooks() {
        return books;
    }
    public int getInstance(String book) {
        for (int i = 0; i <usesize ; i++) {
            if(book.equals(books[i].getName())){
                return i;
            }
        }
        return -1;
    }
    public void swap(Book n1,Book n2){
        n1.setName(n2.getName());
        n1.setAuthor(n2.getAuthor());
        n1.setPrice(n2.getPrice());
        n1.setType(n2.getType());
        n1.setBorrowed(n2.isBorrowed());
    }
}
